<?php defined('SYSPATH') OR die('No direct access allowed.');

class Dashboard_Controller extends Controller {

	public function __construct()
	{
		parent::__construct();
	}

	public function index()
	{		
		if(!parent::_authenticate()) {
			return;
		}
        parent::_loadContent("HanSIP Dashboard", 'dashboard');

        if($this->session->get('id',false)) {
            $user = $this->user_model->get_user($this->session->get('id'));
            if($user->current()->ID_role==1) {      //ID = administrator
                $this->view->content->icons = array(
                    '<img src="../images/icon_stok.png" alt=""/>'          => "stok",
                    '<img src="../images/icon_menu.png" alt=""/>'          => "menu",
                    '<img src="../images/icon_lokasi.png" alt=""/>'        => "lokasi",
                    '<img src="../images/icon_produksi.png" alt=""/>'      => "produksi",
                    '<img src="../images/icon_inventarisasi.png" alt=""/>' => "inventarisasi",
                    '<img src="../images/icon_pembukuan.png" alt=""/>'     => "pembukuan",
                    '<img src="../images/icon_user.png" alt=""/>'          => "user"
                );
            } else if($user->current()->ID_role==2) {   //ID = owner
                $this->view->content->icons = array(
                    '<img src="../images/icon_stok.png" alt=""/>'          => "stok",
                    '<img src="../images/icon_menu.png" alt=""/>'          => "menu",
                    '<img src="../images/icon_lokasi.png" alt=""/>'        => "lokasi",
                    '<img src="../images/icon_produksi.png" alt=""/>'      => "produksi",
                    '<img src="../images/icon_inventarisasi.png" alt=""/>' => "inventarisasi",
                    '<img src="../images/icon_pembukuan.png" alt=""/>'     => "pembukuan"
                );
            } else if($user->current()->ID_role==3) {      //ID = manajer keuangan
                $this->view->content->icons = array(
                    '<img src="../images/icon_inventarisasi.png" alt=""/>' => "inventarisasi",
                    '<img src="../images/icon_pembukuan.png" alt=""/>'     => "pembukuan",
                );
            } else if($user->current()->ID_role==4) {      //ID = manajer produksi
                $this->view->content->icons = array(
                    '<img src="../images/icon_stok.png" alt=""/>'          => "stok",
                    '<img src="../images/icon_menu.png" alt=""/>'          => "menu",
                    '<img src="../images/icon_lokasi.png" alt=""/>'        => "lokasi",
                    '<img src="../images/icon_produksi.png" alt=""/>'      => "produksi"
                );
            }
        }

//        $this->view->content->icons = array(
//            '<img src="../images/icon_stok.png" alt=""/>'          => "stok",
//            '<img src="../images/icon_menu.png" alt=""/>'          => "menu",
//            '<img src="../images/icon_lokasi.png" alt=""/>'        => "lokasi",
//            '<img src="../images/icon_produksi.png" alt=""/>'      => "produksi",
//            '<img src="../images/icon_inventarisasi.png" alt=""/>' => "inventarisasi",
//            '<img src="../images/icon_pembukuan.png" alt=""/>'     => "pembukuan",
//            '<img src="../images/icon_user.png" alt=""/>'          => "user"
//        );
        
        $this->view->render(TRUE);
	}
}